package com.wandian.cqcsk.adapter.mine;


import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wandian.cqcsk.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 我的-适配器
 */
public class MineSetNewsTableRecycleAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private boolean isEdit = false;
    private List<String> selectList = new ArrayList<>();
    public MineSetNewsTableRecycleAdapter(int layoutResId,List defaultList) {
        super(layoutResId);
        this.selectList = defaultList;
    }


    @Override
    protected void convert(BaseViewHolder helper, String item) {
        TextView tv_btn_text = helper.getView(R.id.tv_btn_text);
        tv_btn_text.setText(item+"");
        tv_btn_text.setTextColor(mContext.getResources().getColor(R.color.colorthree));
        tv_btn_text.setBackground(mContext.getResources().getDrawable(R.drawable.button_sys_color_circle_stroke_selector));
        ImageView iv_edit = helper.getView(R.id.iv_edit);
        iv_edit.setVisibility(View.GONE);
        selectItem(iv_edit,tv_btn_text,item);
    }

    private void selectItem(ImageView imageView,TextView textView,String itemText){
        for(String text:selectList){
            if(itemText.equals(text)){
                textView.setTextColor(mContext.getResources().getColor(R.color.white));
                textView.setBackground(mContext.getResources().getDrawable(R.drawable.button_sys_circle_ball));
                if(isEdit) imageView.setVisibility(View.VISIBLE);
                return;
            }
        }
    }

    public void notifySelectState(boolean isEdit,List select){
        this.isEdit = isEdit;
        this.selectList = select;
        notifyDataSetChanged();
    }

}
